package com.kuang.service.controller;

import com.kuang.bascic.utils.AjaxResult;
import com.kuang.bascic.utils.PageList;
import com.kuang.pet.domain.Pet;
import com.kuang.service.domian.PetProduct;
import com.kuang.service.query.PetProductQuery;
import com.kuang.service.service.PetProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/service")
public class PetProductController {
    @Autowired
    private PetProductService petProductService;
    @PostMapping
    public PageList<PetProduct> selectPage(@RequestBody PetProductQuery petProductQuery){
        PageList<PetProduct> petPageList = petProductService.pageList(petProductQuery);
        return petPageList;
    }
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id){
        try {
            PetProduct detil = petProductService.detil(id);
            return AjaxResult.me().setResultObj(detil);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("网络错误");
        }
}}
